<?php if(!defined("HDPHP_PATH"))exit;C("SHOW_NOTICE",FALSE);?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Document</title>
	<link rel="stylesheet" href="http://localhost/shop/Public/Bootstrap/Css/bootstrap.min.css" />
	<link rel="stylesheet" href="http://localhost/shop/Application/Admin/View/Public/Css/common.css" />
	<script type="text/javascript" src='http://localhost/shop/Application/Admin/View/Public/Js/jquery-1.7.2.min.js'></script>
	<style type="text/css">
		body{
			margin-bottom: 100px;
		}
	</style>
</head>
<body>
	<div class="container-fluid">
	<div class="row-fluid">
	<div class="span12">
	<form action="<?php echo U('GoodsList/edit');?>" method='post'>
		<table class='table table-bordered table-hover'>
			<tr>
				<th>货品ID</th>
				<?php if(is_array($AttrData)){?><?php  foreach($AttrData as $key=>$v){ ?>
				<th><?php echo $v['taname'];?></th>
				<?php }}?>
				<th >库存</th>
				<th >货号</th>
				<th>操作</th>
			</tr>
			<?php if(is_array($listData)){?><?php  foreach($listData as $key=>$v){ ?>
				<tr class="info">
					<td><?php echo $v['glid'];?></td>
					<?php if(is_array($v['spec'])){?><?php  foreach($v['spec'] as $key=>$value){ ?>
						<td><?php echo $value;?></td>
					<?php }}?>
					<td >
						<input type="text" name='inventory' value="<?php echo $v['inventory'];?>" style="width:180px;"/>
					</td>
					<td >
						<input type="text" name='number' value="<?php echo $v['number'];?>"  style="width:180px;" />
					</td>
					<td>
						<input type="hidden" name='glid' value='<?php echo $_GET['glid'];?>'/>
						<input type="submit" value='保存修改' class="btn btn-primary"/>
					</td>
				</tr>
			<?php }}?>
			<!-- 如果已添加数目小于可能情况数目，才出现添加货品的输入框 -->
			<!-- <tr class="info" >
				<td>添加货品</td>
					<?php if(is_array($AttrData)){?><?php  foreach($AttrData as $key=>$v){ ?>
						<td>
							<select name="spec[]" style="width:180px;">
								<option value="0">-请选择-</option>
								<?php if(is_array($v['opt'])){?><?php  foreach($v['opt'] as $key=>$value){ ?>
									<option value="<?php echo $value['gaid'];?>"><?php echo $value['gtvalue'];?></option>
								<?php }}?>
							</select>
						</td>
					<?php }}?>
				<td>
					<input type="text" name='inventory' style="width:180px;"/>
				</td>
				<td width="180px">
					<input type="text" name='number' value=""  style="width:180px;" />
				</td>
				<td></td>
			</tr> -->
		</table>
	</form>

	</div>
	</div>
	</div>


<script type="text/javascript">
	var sel = $('select[name="spec[]"]');
	var len = sel.length;
	sel.change(function () {
		var remote = {
			'gid' : <?php echo $_GET['gid'];?>,
			'spec' : {}
		};
		for (var i = 0; i < len; ++i)
		{
			if (sel.eq(i).val() == 0)
			{
				return;
			}
			else
			{
				remote.spec[i] = sel.eq(i).val();
			}
		}
		$.ajax({
			url : '<?php echo U("GoodsList/check");?>',
			type : 'post',
			data : remote,
			dataType : 'json',
			success : function(data)
			{
				if (data == 0)
				{
					alert('货品已存在，如果要修改库存，请点击修改');
					for (var i = 0; i < len; ++i)
					{
						sel.eq(i).val(0);
					}
				}
			}
		});
	});
</script>
</body>
</html>